//生成任意区间的随机值
function rand(min, max) {
    return Math.round(Math.random() * (max - min) + min);
}
let oInputs = document.querySelectorAll("input");
let oP = document.querySelectorAll("p");
// 手机号
oInputs[0].onblur = function() {
        let regPhone = /^1(5|3|8|7|9)\d{9}$/;
        if (this.value == "") {
            oP[0].innerHTML = "手机号不能为空";
            flagName = false;
        } else if (!regPhone.test(this.value)) {
            oP[0].innerHTML = "请输入正确的手机格式";
            flagName = false;
        } else {
            oP[0].innerHTML = "";
            flagName = true;
        }
    }
    // 验证码
oInputs[2].onclick = function() {
    let str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    let str1 = " ";
    for (let i = 0; i < 4; i++) {
        str1 += str.charAt(rand(0, 58));
    }
    oInputs[1].value = str1;
    str1 = " ";
}



let _regNum = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/;
oInputs[3].onblur = function() {
    if (this.value == "") {
        oP[2].innerHTML = "密码不能为空";
        flagName = false;
    } else if (!_regNum.test(this.value)) {
        oP[2].innerHTML = "密码格式不正确";
        flagName = false;
    } else {
        oP[2].innerHTML = "";
        flagName = true;
    }
}
oInputs[4].onblur = function() {

    if (this.value == "") {
        oP[3].innerHTML = "密码不能为空";
        flagName = false;
    } else if (this.value != oInputs[3].value) {
        oP[3].innerHTML = "密码不一致,请重新输入";
        flagName = false;
    } else {
        oP[3].innerHTML = "";
        flagName = true;
    }
}



